//=============================================================================
//
//  Copyright (C) 2020 All rights reserved.
//
//  Filename:		mod.rs
//
//  Author: Wang Zhecheng - wangzhecheng@yeah.net
//
//  Date: 2020-09-22 00:32
//
//  Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
//
//  Last modified:	2020-11-06 18:27
//
//  Description:
//
//===========================================================================*/
pub mod tensor;
pub mod tensor_ops;
pub mod time_func;

use crate::Real;

#[allow(dead_code)]
#[inline]
pub fn sind(degree: Real) -> Real {
    (degree % 360.).to_radians().sin()
}
#[allow(dead_code)]
#[inline]
pub fn cosd(degree: Real) -> Real {
    (degree % 360.).to_radians().cos()
}
#[allow(dead_code)]
#[inline]
pub fn tand(degree: Real) -> Real {
    (degree % 360.).to_radians().tan()
}

#[test]
fn test_degree() {
    use crate::consts::{ROOT2, ROOT3};
    use approx::assert_relative_eq;
    assert_relative_eq!(sind(0.), 0., max_relative = 0.01);
    assert_relative_eq!(sind(30.), 0.5, max_relative = 0.01);
    assert_relative_eq!(sind(45.), ROOT2 * 0.5, max_relative = 0.01);
    assert_relative_eq!(sind(60.), ROOT3 * 0.5, max_relative = 0.01);
    assert_relative_eq!(sind(90.), 1., max_relative = 0.01);
}
